﻿using System.Linq;
using Fuse8.ContentManagementFramework.BizFacade.Services.Contents.Queryable;
using Fuse8.ContentManagementFramework.Domain;
using Fuse8.DomainFramework.Domain;

namespace Fuse8.ContentManagementFramework.BizFacade.Services.Contents
{
    /// <summary>
    /// Provides methods for working with CMS content items via strong-typed entity
    /// </summary>
    /// <typeparam name="TEntity"></typeparam>
    public static class ContentService<TEntity> where TEntity : class, IContentItem, IEntityObject<int>, new()
    {
        /// <summary>
        /// Get Content provider for current context
        /// </summary>
        public static IContentProvider<TEntity> Provider
        {
            get { return new FrontEndContentProvider<TEntity>(); }
        }
    }

    public static class GenericContentService
    {
        public static IQueryable<GenericCmsEntity> GetAll(int typeId)
        {
            return new CmsContentQueryable(typeId);
        }

        public static IQueryable<GenericCmsEntity> GetAllRevisions(int typeId)
        {
            return new CmsContentQueryable(typeId, true);
        }
    }
}